'use strict'
// import LocalInfoManager from './LocalInfo.js';
//  import GlobalConstant from './GlobalConstant';

let instance = null
// let _account = null;

class UserManager {
  constructor () {
    if (!instance) {
      instance = this
    }
    return instance
  }

  // static defaultManager() {
  //   return new AccountManager();
  // }
  //
  // run() {
  //   this.accountPicker(10);
  // }

  // 递归获取本地用户  避免获取异常 尝试10次获取
  // accountPicker(localInfoCount) {
  //   LocalInfoManager.getLoginedAccount().then((account) => {
  //     // _account = account;
  //   }, () => {
  //     if (localInfoCount === 0) {
  //       return;
  //     }
  //     this.accountPicker(localInfoCount - 1);
  //   });
  // }

  // static setUserInfo (data) {
  //   let {openId, signCode, loginMobile, cardNo, mobileSecret} = {...this.getAccount(true), ...data};
  //   openId = openId || ''
  //   signCode = signCode || ''
  //   loginMobile = loginMobile || ''
  //   cardNo = cardNo || ''
  //   mobileSecret = mobileSecret || ''
  //   window.localStorage.setItem('openId', openId)
  //   window.localStorage.setItem('signCode', signCode)
  //   window.localStorage.setItem('loginMobile', loginMobile)
  //   window.localStorage.setItem('mobileSecret', mobileSecret)
  //   window.localStorage.setItem('cardNo', cardNo)
  //   GlobalConstant.store.commit('UPDATE_LOGIN', {openId, signCode, loginMobile, cardNo, mobileSecret});
  // }

  // static getUserInfo(){
  //   if (isPersistence){
  //     let openId = window.localStorage.openId;
  //     let signCode = window.localStorage.signCode;
  //     let loginMobile = window.localStorage.loginMobile;
  //     let cardNo = window.localStorage.cardNo;
  //     let mobileSecret = window.localStorage.mobileSecret;
  //     return {openId, signCode, loginMobile, cardNo, mobileSecret};
  //   } else {
  //     return GlobalConstant.store.state.login.loginInfo || {}
  //   }
  // }
  //
  // static updateAccount(account){
  //   let _a = {};
  //   for (let key in account){
  //     if (account.hasOwnProperty(key)){
  //       window.localStorage.setItem(key, account[key])
  //       _a[key] = account[key];
  //     }
  //   }
  //   GlobalConstant.store.commit('UPDATE_LOGIN', _a);
  // }
  //
  // static isLogin(isPersistence) {
  //   if (isPersistence) {
  //     if (!window.localStorage.loginMobile || window.localStorage.loginMobile === ''){
  //       return false;
  //     }
  //     if (!window.localStorage.mobileSecret || window.localStorage.mobileSecret === ''){
  //       return false;
  //     }
  //     if (!window.localStorage.openId || window.localStorage.openId === ''){
  //       return false;
  //     }
  //     if (!window.localStorage.signCode || window.localStorage.signCode === ''){
  //       return false;
  //     }
  //     return true;
  //   } else {
  //     return GlobalConstant.store.state.login.loginInfo.loginMobile && GlobalConstant.store.state.login.loginInfo.loginMobile !== '' &&
  //       GlobalConstant.store.state.login.loginInfo.mobileSecret && GlobalConstant.store.state.login.loginInfo.mobileSecret !== '' &&
  //       GlobalConstant.store.state.login.loginInfo.openId && GlobalConstant.store.state.login.loginInfo.openId !== '' &&
  //       GlobalConstant.store.state.login.loginInfo.signCode && GlobalConstant.store.state.login.loginInfo.signCode !== '';
  //   }
  // }

  // static clearInfo() {
  //     // window.localStorage.setItem('uid', '');
  //     // window.localStorage.setItem('token', '');
  //   window.localStorage.removeItem('token');
  //   GlobalConstant.store.commit('isLogin', false)
  // }
}

export default UserManager
